package com.xyzwps.harbor.service;

import com.xyzwps.harbor.model.Seq;
import com.xyzwps.harbor.repo.SeqRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Primary
@Service
public class DBIdGenerator implements UserIdGenerator {

    @Autowired
    private SeqRepository seqRepository;

    @Override
    public Mono<Long> generate() {
        return seqRepository.save(new Seq()).map(Seq::getId);
    }
}